/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package clusteranalyst2;

import Control.CCache;
import java.util.HashMap;
import java.util.Set;


/**
 *
 * @author jlh
 */
//注释：我们把数据源中的每一行数据叫做一个类class，但是进行预处理后的哈希表的每一行我们叫做行row
//注释：我们把哈希表中的行叫做rowKey,列叫做colKey;把由哈希表组成的数据的行列号叫做rowArr,colArr

public class ExcuteCluster {

    public void excute()
    {
        double [][] distanceMatrix;
        int rowSize;
        CaclAbsDistance cb=new CaclAbsDistance();
        distanceMatrix=cb.getAbsDistance();
        //转换为HashMap
        MathMethods mm=new MathMethods();
        HashMap disMatrixOld=new HashMap(GlobalVar.hmCapacity);
        disMatrixOld=mm.matrixToHashMap(distanceMatrix);
        //GlobalVar.currentClassNum=disMatrixOld.size()+1;
        //Proble here 初始的currentClassNum设置错误
        //计算距离矩阵的size，然后复制给全局变量
//         Set keys=disMatrixOld.keySet();
//         Object[] keyArray=keys.toArray();
//         int arrLen=keyArray.length;
//         System.out.println("excute中的arrLen:"+arrLen);
//        GlobalVar.currentClassNum=Integer.parseInt(keyArray[arrLen-1].toString())+1;
       
         //System.out.println("初始化currentClassNum的值："+GlobalVar.currentClassNum);
        
        rowSize=disMatrixOld.size()-2;
        HashMap disMatrixNew=new HashMap(GlobalVar.hmCapacity);
       for(int i=0;i<rowSize;i++)
       {        
         System.out.println("hm"+(i+1));
         RefactorHashMap rhm=new RefactorHashMap();
         disMatrixNew=rhm.excuteRefactor(disMatrixOld);
         //hm2=RefactorHashMap(hm);
         disMatrixOld=disMatrixNew;
       }   

  CCache.getCache().PushClusterIntoDB();
  //System.out.println("The Row size:"+rowSize);
    }


}

